<?php
include_once 'common/tools.php';
//启用一个带有ob_gzip压缩机的工作台
ob_start('ob_gzip');

$id = $_GET["id"];
$uId = $_GET["uId"];

$config = require 'conf/config.ini.php';      //加载公用config.ini.php
$conn = mysql_connect($config["DB_HOST"], $config["DB_USER"], $config["DB_PWD"]);
mysql_select_db($config["DB_NAME"], $conn);
mysql_query("SET NAMES utf8");

$sql = "select t.topicId id, t.topicContent content, u.userId, (select userId from live_user where id = t.atUserId) atUserId, u.id uId, u.userPic, u.userCity, u.userSex, u.userSign, IF(u.userBirthDay <> '0000-00-00', (YEAR(CURDATE())-YEAR(u.userBirthDay))-(RIGHT(CURDATE(),5)<RIGHT(u.userBirthDay,5)), '0') userAge, t.updateDate, ".
		"IFNULL((select fState from live_friend where ((fromUserId = " . $uId . " and toUserId = u.id) or (toUserId = " . $uId . " and fromUserId = u.id) or (fromUserId = u.id and toUserId = 0))),'-1') f ".
		"from live_topic t ,live_user u ".
		"where  ".
		"	 u.id = t.userId ".
		"and t.replayId = " . $id . " ".
		"order by t.updateDate desc";
$newsList = mysql_query($sql, $conn);
while ($news = mysql_fetch_object($newsList)) {
	$newsArray[] = $news;
}
//echo '{"sql":"' . $sql . '","results":' . json_encode($newsArray) . '}';
echo '{"results":' . json_encode($newsArray) . '}';
//输出压缩成果
ob_end_flush();
?>